<template>
    <popup
        class="mr-2 inline"
        width="800px"
        :clickModalClose="false"
        title="提现审核"
        @confirm="handleconfirm"
    >
        <template #trigger>
            <el-link type="primary" :underline="false">{{ title }}</el-link>
        </template>

        <div class="ml-6">
            <el-form
                :model="formData"
                label-width="120px"
                class="w-[540px]"
                :rules="formRules"
                ref="formRef"
            >
                <el-form-item label="提现审核" prop="withdrawpass">
                    <el-radio-group v-model="formData.withdrawpass" class="ml-4">
                        <el-radio :label="1">审核通过</el-radio>
                        <el-radio :label="2">审核拒绝</el-radio>
                    </el-radio-group>
                    <div class="form-tips">审核拒绝后，提现金额会全部退回佣金账户</div>
                </el-form-item>
                <el-form-item label="提现说明">
                    <el-input
                        :rows="3"
                        type="textarea"
                        placeholder="请输入提现说明"
                        show-word-limit
                        maxlength="20"
                        v-model="formData.verify_remark"
                    ></el-input>
                </el-form-item>
            </el-form>
        </div>
    </popup>
</template>

<script lang="ts" setup>
import { withdrawRefuse, withdrawPass, withdrawList } from '@/api/finance'
import Popup from '@/components/popup/index.vue'
const props = withDefaults(
    defineProps<{
        id: string | number
        title: string
    }>(),
    {
        id: '',
        title: ''
    }
)
const formData = ref<any>({
    id: props.id,
    verify_remark: '',
    withdrawpass: 1
})
const emit = defineEmits(['refresh'])

const formRules = {
    withdrawpass: [
        {
            required: true,
            message: '请选择',
            trigger: ['blur', 'change']
        }
    ]
}
const handleconfirm = async () => {
    if (formData.value.withdrawpass === 1) {
        await withdrawPass(formData.value)
        return emit('refresh')
    }
    await withdrawRefuse(formData.value)
    emit('refresh')
}
</script>

<style lang="scss" scoped>
// todo
:deep(.el-dialog__footer) {
    text-align: center;
}
</style>
